<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <iframe src="http://b.yueqizhixiang.com:8080/script.html" id='iframe'></iframe>
    <script>
        document.domain = 'yueqizhixiang.com'
        window.onload = function () {
            var iframe = document.getElementById('iframe');
            var wn = iframe.contentWindow;//这里能够获取到iframe的window， 但是该window的属性大部分不能够使用
            console.log('contentWindow:');
            console.log(wn.name);
            var doc = wn.document; //这里获取不到iframe的document
            console.log(doc.getElementById('id'))
        }

    </script>
</body>

</html>